local skel = fk.CreateSkill {
  name = "lb__fengxi",
}

Fk:loadTranslationTable {
  ["lb__fengxi"] = "风息",
  --[":lb__fengxi"] = "每阶段限一次，当一张伤害牌结算后，若至少两名角色因此受到伤害，你可以摸一张牌并横置因此受伤的所有角色，然后令因此受伤的前两名角色各回复1点体力。",
  --9.23
  [":lb__fengxi"] = "每阶段限一次，当一张伤害牌结算后，若至少两名角色因此受到伤害，你可以摸一张牌并横置因此受伤的所有角色，然后令因此受伤的任意名角色各回复1点体力。",

  ["#lb__fengxi"] = "风息：你可以摸一张牌并横置因 %arg 受伤的所有角色，然后令因此受伤的任意名角色各回复1点体力",
  ["#lb__fengxi_choose"] = "风息：你可以令任意名因 %arg 受伤的角色各回复1点体力",

  ["$lb__fengxi1"] = "请为我们照亮前路。",
  ["$lb__fengxi2"] = "重见澄澈晴空。",
}

skel:addEffect(fk.CardUseFinished, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and data.card.is_damage_card 
    and data.damageDealt
    and player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0 then
      local tos = table.filter(player.room.alive_players, function (to)
        return data.damageDealt[to] and data.damageDealt[to] > 0
      end)
      if #tos > 1 then
        event:setCostData(self, { tos = tos })
        return true
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player,
      { skill_name = skel.name, prompt = "#lb__fengxi:::" .. data.card:toLogString() })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local tos = event:getCostData(self).tos
    --local recover = table.slice(tos, 1, 3)
    room:sortByAction(tos)
    player:drawCards(1, skel.name)
    for _, t in ipairs(tos) do
      if not t.dead and not t.chained then
        t:setChainState(true)
      end
    end
    tos = table.filter(tos, function (to)
      return not to.dead
    end)
    if #tos == 0 then return end
    local recover = room:askToChoosePlayers(player, {
      targets = tos,
      min_num = 1,
      max_num = #tos,
      skill_name = skel.name,
      prompt = "#lb__fengxi_choose:::" .. data.card:toLogString(),
      cancelable = true,
    })
    if #tos > 0 then
      room:sortByAction(recover)
      for _, t in ipairs(recover) do
        if not t.dead and t:isWounded() then
          room:recover {
            who = t,
            num = 1,
            skillName = skel.name,
            recoverBy = player,
          }
        end
      end
    end
  end,
})

return skel